Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports System.Text

Namespace Phoenix.Tools.Win32
  ''' <summary>
  ''' Windows API Functions
  ''' </summary>
  Public Class WindowsAPI
	#Region "Constructors"
	' No need to construct this object
	Private Sub New()
	End Sub
	#End Region

	#Region "Constans values"
	Public Const TOOLBARCLASSNAME As String = "ToolbarWindow32"
	Public Const REBARCLASSNAME As String = "ReBarWindow32"
	Public Const PROGRESSBARCLASSNAME As String = "msctls_progress32"
	Public Const SCROLLBAR As String = "SCROLLBAR"
	#End Region

	#Region "CallBacks"
	Public Delegate Function HookProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
	#End Region

	#Region "Kernel32.dll functions"
	<DllImport("kernel32.dll", ExactSpelling:=True, CharSet:=CharSet.Auto)> _
	Public Shared Function GetCurrentThreadId() As Integer
	End Function
	<DllImport("kernel32.dll", ExactSpelling:=True, CharSet:=CharSet.Auto)> _
	Public Shared Function GetLastError() As Integer
	End Function

	<DllImport("kernel32.dll", ExactSpelling:=True, CharSet:=CharSet.Auto)> _
	Public Shared Sub SetLastError(ByVal error_Renamed As Integer)
	End Sub
	#End Region

	#Region "Gdi32.dll functions"
	<DllImport("gdi32.dll")> _
	Shared Public Function StretchBlt(ByVal hDCDest As IntPtr, ByVal XOriginDest As Integer, ByVal YOriginDest As Integer, ByVal WidthDest As Integer, ByVal HeightDest As Integer, ByVal hDCSrc As IntPtr, ByVal XOriginScr As Integer, ByVal YOriginSrc As Integer, ByVal WidthScr As Integer, ByVal HeightScr As Integer, ByVal Rop As System.UInt32) As Boolean
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function CreateCompatibleDC(ByVal hDC As IntPtr) As IntPtr
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function CreateCompatibleBitmap(ByVal hDC As IntPtr, ByVal Width As Integer, ByVal Heigth As Integer) As IntPtr
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function SelectObject(ByVal hDC As IntPtr, ByVal hObject As IntPtr) As IntPtr
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function BitBlt(ByVal hDCDest As IntPtr, ByVal XOriginDest As Integer, ByVal YOriginDest As Integer, ByVal WidthDest As Integer, ByVal HeightDest As Integer, ByVal hDCSrc As IntPtr, ByVal XOriginScr As Integer, ByVal YOriginSrc As Integer, ByVal Rop As System.UInt32) As Boolean
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function DeleteDC(ByVal hDC As IntPtr) As IntPtr
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function PatBlt(ByVal hDC As IntPtr, ByVal XLeft As Integer, ByVal YLeft As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Rop As System.UInt32) As Boolean
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function DeleteObject(ByVal hObject As IntPtr) As Boolean
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function GetPixel(ByVal hDC As IntPtr, ByVal XPos As Integer, ByVal YPos As Integer) As System.UInt32
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function SetMapMode(ByVal hDC As IntPtr, ByVal fnMapMode As Integer) As Integer
	End Function
	<DllImport("gdi32.dll")> _
	Shared Public Function GetObjectType(ByVal handle As IntPtr) As Integer
	End Function
'INSTANT VB NOTE: The parameter hdc was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
	<DllImport("gdi32")> _
	Public Shared Function CreateDIBSection(ByVal hdc_Renamed As IntPtr, ByRef bmi As BITMAPINFO_FLAT, ByVal iUsage As Integer, ByRef ppvBits As Integer, ByVal hSection As IntPtr, ByVal dwOffset As Integer) As IntPtr
	End Function
	<DllImport("gdi32")> _
	Public Shared Function GetDIBits(ByVal hDC As IntPtr, ByVal hbm As IntPtr, ByVal StartScan As Integer, ByVal ScanLines As Integer, ByVal lpBits As Integer, ByVal bmi As BITMAPINFOHEADER, ByVal usage As Integer) As Integer
	End Function
	<DllImport("gdi32")> _
	Public Shared Function GetDIBits(ByVal hdc_Renamed As IntPtr, ByVal hbm As IntPtr, ByVal StartScan As Integer, ByVal ScanLines As Integer, ByVal lpBits As Integer, ByRef bmi As BITMAPINFO_FLAT, ByVal usage As Integer) As Integer
	End Function
	<DllImport("gdi32")> _
	Public Shared Function GetPaletteEntries(ByVal hpal As IntPtr, ByVal iStartIndex As Integer, ByVal nEntries As Integer, ByVal lppe As Byte()) As IntPtr
	End Function
	<DllImport("gdi32")> _
	Public Shared Function GetSystemPaletteEntries(ByVal hdc_Renamed As IntPtr, ByVal iStartIndex As Integer, ByVal nEntries As Integer, ByVal lppe As Byte()) As IntPtr
	End Function
	<DllImport("gdi32")> _
	Public Shared Function SetDCBrushColor(ByVal hdc_Renamed As IntPtr, ByVal crColor As System.UInt32) As System.UInt32
	End Function
	<DllImport("gdi32")> _
	Public Shared Function CreateSolidBrush(ByVal crColor As System.UInt32) As IntPtr
	End Function
	<DllImport("gdi32")> _
	Public Shared Function SetBkMode(ByVal hDC As IntPtr, ByVal mode As BackgroundMode) As Integer
	End Function
	<DllImport("gdi32")> _
	Public Shared Function SetViewportOrgEx(ByVal hdc_Renamed As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal param As Integer) As Integer
	End Function
	<DllImport("gdi32")> _
	Public Shared Function SetTextColor(ByVal hDC As IntPtr, ByVal colorRef As System.UInt32) As System.UInt32
	End Function
	<DllImport("gdi32")> _
	Public Shared Function SetStretchBltMode(ByVal hDC As IntPtr, ByVal StrechMode As Integer) As Integer
	End Function
	#End Region

	#Region "Uxtheme.dll functions"
	<DllImport("uxtheme.dll")> _
	Shared Public Function SetWindowTheme(ByVal hWnd As IntPtr, ByVal AppID As String, ByVal ClassID As String) As Integer
	End Function
	#End Region

	#Region "User32.dll functions"
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetDC(ByVal hWnd As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Sub PostQuitMessage(ByVal exitCode As Integer)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ReleaseDC(ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetDesktopWindow() As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ShowWindow(ByVal hWnd As IntPtr, ByVal State As Short) As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function UpdateWindow(ByVal hWnd As IntPtr) As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SetForegroundWindow(ByVal hWnd As IntPtr) As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SetWindowPos(ByVal hWnd As IntPtr, ByVal hWndInsertAfter As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal flags As System.UInt32) As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function OpenClipboard(ByVal hWndNewOwner As IntPtr) As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function CloseClipboard() As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function EmptyClipboard() As Boolean
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SetClipboardData(ByVal Format As System.UInt32, ByVal hData As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetMenuItemRect(ByVal hWnd As IntPtr, ByVal hMenu As IntPtr, ByVal Item As System.UInt32, ByRef rc As RECT) As Boolean
	End Function
	<DllImport("user32.dll", ExactSpelling:=True, CharSet:=CharSet.Auto)> _
	Public Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
	End Function
        '<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
        'Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByRef wParam As Integer, ByRef lParam As Integer) As IntPtr
        'End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As MSG) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As TOOLINFO) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As SpinControlMsg, ByVal wParam As Integer, ByRef lParam As UDACCEL) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As RECT)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As POINT) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As TBBUTTON)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As TBBUTTONINFO)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As REBARBANDINFO) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As TVITEM)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As LVITEM)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef lParam As HDITEM)
	End Sub
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Sub SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef hti As HD_HITTESTINFO)
	End Sub
'INSTANT VB NOTE: The parameter format was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByRef format_Renamed As PARAFORMAT2) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SendDlgItemMessage(ByVal hWnd As IntPtr, ByVal Id As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetWindowsHookEx(ByVal hookid As Integer, ByVal pfnhook As HookProc, ByVal hinst As IntPtr, ByVal threadid As Integer) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
	Public Shared Function UnhookWindowsHookEx(ByVal hhook As IntPtr) As Boolean
	End Function
'INSTANT VB NOTE: The parameter wparam was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
'INSTANT VB NOTE: The parameter lparam was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
	<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
	Public Shared Function CallNextHookEx(ByVal hhook As IntPtr, ByVal code As Integer, ByVal wparam_Renamed As IntPtr, ByVal lparam_Renamed As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetFocus(ByVal hWnd As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function DrawText(ByVal hdc_Renamed As IntPtr, ByVal lpString As String, ByVal nCount As Integer, ByRef lpRect As RECT, ByVal uFormat As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetParent(ByVal hChild As IntPtr, ByVal hParent As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetDlgItem(ByVal hDlg As IntPtr, ByVal nControlID As Integer) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetClientRect(ByVal hWnd As IntPtr, ByRef rc As RECT) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function InvalidateRect(ByVal hWnd As IntPtr, ByVal rect As IntPtr, ByVal bErase As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function InvalidateRect(ByVal hWnd As IntPtr, ByRef rect As RECT, ByVal bErase As Integer) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function WaitMessage() As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function PeekMessage(ByRef msg As MSG, ByVal hWnd As Integer, ByVal wFilterMin As System.UInt32, ByVal wFilterMax As System.UInt32, ByVal wFlag As System.UInt32) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetMessage(ByRef msg As MSG, ByVal hWnd As Integer, ByVal wFilterMin As System.UInt32, ByVal wFilterMax As System.UInt32) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function TranslateMessage(ByRef msg As MSG) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function DispatchMessage(ByRef msg As MSG) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function LoadCursor(ByVal hInstance As IntPtr, ByVal cursor As System.UInt32) As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetCursor(ByVal hCursor As IntPtr) As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetFocus() As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function ReleaseCapture() As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function BeginPaint(ByVal hWnd As IntPtr, ByRef ps As PAINTSTRUCT) As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function EndPaint(ByVal hWnd As IntPtr, ByRef ps As PAINTSTRUCT) As Boolean
	End Function
'INSTANT VB NOTE: The parameter hwnd was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
'INSTANT VB NOTE: The parameter hdcSrc was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function UpdateLayeredWindow(ByVal hwnd_Renamed As IntPtr, ByVal hdcDst As IntPtr, ByRef pptDst As POINT, ByRef psize As SIZE, ByVal hdcSrc_Renamed As IntPtr, ByRef pprSrc As POINT, ByVal crKey As Int32, ByRef pblend As BLENDFUNCTION, ByVal dwFlags As Int32) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef rect As RECT) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function ClientToScreen(ByVal hWnd As IntPtr, ByRef pt As POINT) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function TrackMouseEvent(ByRef tme As TRACKMOUSEEVENTS) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetWindowRgn(ByVal hWnd As IntPtr, ByVal hRgn As IntPtr, ByVal redraw As Boolean) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetKeyState(ByVal virtKey As Integer) As System.UInt16
	End Function
'INSTANT VB NOTE: The parameter width was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
'INSTANT VB NOTE: The parameter height was renamed since Visual Basic will not uniquely identify local variables when parameters have the same name:
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal width_Renamed As Integer, ByVal height_Renamed As Integer, ByVal repaint As Boolean) As Boolean
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetClassName(ByVal hWnd As IntPtr, <System.Runtime.InteropServices.Out()> ByRef ClassName As STRINGBUFFER, ByVal nMaxCount As Integer) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As IntPtr) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As System.Int32
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetDCEx(ByVal hWnd As IntPtr, ByVal hRegion As IntPtr, ByVal flags As System.UInt32) As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function FillRect(ByVal hDC As IntPtr, ByRef rect As RECT, ByVal hBrush As IntPtr) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetWindowPlacement(ByVal hWnd As IntPtr, ByRef wp As WINDOWPLACEMENT) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function SetWindowText(ByVal hWnd As IntPtr, ByVal text As String) As Integer
	End Function
	<DllImport("User32.dll", CharSet:=CharSet.Auto)> _
	Public Shared Function GetWindowText(ByVal hWnd As IntPtr, <System.Runtime.InteropServices.Out()> ByRef text As STRINGBUFFER, ByVal maxCount As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SetClipboardViewer(ByVal hWndNewViewer As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ChangeClipboardChain(ByVal hWndRemove As IntPtr, ByVal hWndNewNext As IntPtr) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetSystemMetrics(ByVal nIndex As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function SetScrollInfo(ByVal hwnd_Renamed As IntPtr, ByVal bar As Integer, ByRef si As SCROLLINFO, ByVal fRedraw As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal bar As Integer, ByVal show As Integer) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function EnableScrollBar(ByVal hWnd As IntPtr, ByVal flags As System.UInt32, ByVal arrows As System.UInt32) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function BringWindowToTop(ByVal hWnd As IntPtr) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetScrollInfo(ByVal hwnd_Renamed As IntPtr, ByVal bar As Integer, ByRef si As SCROLLINFO) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ScrollWindowEx(ByVal hWnd As IntPtr, ByVal dx As Integer, ByVal dy As Integer, ByRef rcScroll As RECT, ByRef rcClip As RECT, ByVal UpdateRegion As IntPtr, ByRef rcInvalidated As RECT, ByVal flags As System.UInt32) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function IsWindow(ByVal hWnd As IntPtr) As Integer
	End Function
	<DllImport("shell32.Dll", CharSet:=CharSet.Auto)> _
	Shared Public Function Shell_NotifyIcon(ByVal cmd As NotifyCommand, ByRef data As NOTIFYICONDATA) As Integer
	End Function
	<DllImport("User32.Dll", CharSet:=CharSet.Auto)> _
	Shared Public Function TrackPopupMenuEx(ByVal hMenu As IntPtr, ByVal uFlags As System.UInt32, ByVal x As Integer, ByVal y As Integer, ByVal hWnd As IntPtr, ByVal ignore As IntPtr) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetCursorPos(ByRef pnt As POINT) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function GetCaretPos(ByRef pnt As POINT) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function ValidateRect(ByVal hWnd As IntPtr, ByRef rc As RECT) As Integer
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function FindWindowEx(ByVal hWnd As IntPtr, ByVal hChild As IntPtr, ByVal strClassName As String, ByVal strName As String) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function FindWindowEx(ByVal hWnd As IntPtr, ByVal hChild As IntPtr, ByVal strClassName As String, ByVal strName As IntPtr) As IntPtr
	End Function
	<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
	Shared Public Function AnimateWindow(ByVal hWnd As IntPtr, ByVal dwTime As System.UInt32, ByVal dwFlags As System.UInt32) As Integer
	End Function
	#End Region

	#Region "Common Controls functions"
	<DllImport("comctl32.dll")> _
	Public Shared Function InitCommonControlsEx(ByVal icc As INITCOMMONCONTROLSEX) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function InitCommonControls() As Boolean
	End Function
	<DllImport("comctl32.dll", EntryPoint:="DllGetVersion")> _
	Public Shared Function GetCommonControlDLLVersion(ByRef dvi As DLLVERSIONINFO) As Integer
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_Create(ByVal width_Renamed As Integer, ByVal height_Renamed As Integer, ByVal flags As System.UInt32, ByVal count As Integer, ByVal grow As Integer) As IntPtr
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_Destroy(ByVal handle As IntPtr) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_Add(ByVal imageHandle As IntPtr, ByVal hBitmap As IntPtr, ByVal hMask As IntPtr) As Integer
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_Remove(ByVal imageHandle As IntPtr, ByVal index As Integer) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_BeginDrag(ByVal imageHandle As IntPtr, ByVal imageIndex As Integer, ByVal xHotSpot As Integer, ByVal yHotSpot As Integer) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_DragEnter(ByVal hWndLock As IntPtr, ByVal x As Integer, ByVal y As Integer) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_DragMove(ByVal x As Integer, ByVal y As Integer) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Function ImageList_DragLeave(ByVal hWndLock As IntPtr) As Boolean
	End Function
	<DllImport("comctl32.dll")> _
	Public Shared Sub ImageList_EndDrag()
	End Sub
	#End Region

	#Region "Win32 Macro-Like helpers"
	Public Shared Function GET_X_LPARAM(ByVal lParam As Integer) As Integer
	  Return (lParam And &Hffff)
	End Function


	Public Shared Function GET_Y_LPARAM(ByVal lParam As Integer) As Integer
	  Return (lParam >> 16)
	End Function

	Public Shared Function GetPointFromLPARAM(ByVal lParam As Integer) As Point
	  Return New Point(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))
	End Function

	Public Shared Function LOW_ORDER(ByVal param As Integer) As Integer
	  Return (param And &Hffff)
	End Function

	Public Shared Function HIGH_ORDER(ByVal param As Integer) As Integer
	  Return (param >> 16)
	End Function


	Public Shared Function MAKELONG(ByVal x As Integer, ByVal y As Integer) As Integer
	  Return (x + (y << 16))
	End Function
	#End Region

	#Region "Shell32.Dll"
	<DllImport("shell32.dll")> _
	Shared Public Function ShellExecute(ByVal hwnd As IntPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As IntPtr
	End Function


	''' <summary>
	''' Retrieves a pointer to the Shell's IMalloc interface.
	''' </summary>
	''' <param name="hObject">Address of a pointer that receives the Shell's IMalloc interface pointer.</param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHGetMalloc(<System.Runtime.InteropServices.Out()> ByRef hObject As IntPtr) As Int32
	End Function

	''' <summary>
	''' Retrieves the path of a folder as an PIDL.
	''' </summary>
	''' <param name="hwndOwner">Handle to the owner window.</param>
	''' <param name="nFolder">A CSIDL value that identifies the folder to be located</param>
	''' <param name="hToken">Token that can be used to represent a particular user</param>
	''' <param name="dwReserved">Reserved</param>
	''' <param name="ppidl">Address of a pointer to an item identifier list structure specifying the folder's location relative to the root of the namespace (the desktop).</param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHGetFolderLocation(ByVal hwndOwner As IntPtr, ByVal nFolder As Int32, ByVal hToken As IntPtr, ByVal dwReserved As UInt32, <System.Runtime.InteropServices.Out()> ByRef ppidl As IntPtr) As Int32
	End Function

	''' <summary>
	''' Converts an item identifier list to a file system path. 
	''' </summary>
	''' <param name="pidl">Address of an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop). </param>
	''' <param name="pszPath">Address of a buffer to receive the file system path.</param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHGetPathFromIDList(ByVal pidl As IntPtr, ByVal pszPath As StringBuilder) As Int32
	End Function

	''' <summary>
	''' Takes the CSIDL of a folder and returns the pathname.
	''' </summary>
	''' <param name="hwndOwner">Handle to an owner window.</param>
	''' <param name="nFolder">A CSIDL value that identifies the folder whose path is to be retrieved.</param>
	''' <param name="hToken">An access token that can be used to represent a particular user.</param>
	''' <param name="dwFlags">Flags to specify which path is to be returned. It is used for cases where the folder associated with a CSIDL may be moved or renamed by the user. </param>
	''' <param name="pszPath">Pointer to a null-terminated string which will receive the path.</param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHGetFolderPath(ByVal hwndOwner As IntPtr, ByVal nFolder As Int32, ByVal hToken As IntPtr, ByVal dwFlags As UInt32, ByVal pszPath As StringBuilder) As Int32
	End Function

	''' <summary>
	''' Translates a Shell namespace object's display name into an item 
	''' identifier list and returns the attributes of the object. This function is 
	''' the preferred method to convert a string to a pointer to an item identifier 
	''' list (PIDL). 
	''' </summary>
	''' <param name="pszName">Pointer to a zero-terminated wide string that contains the display name  to parse. </param>
	''' <param name="pBndContext">Optional bind context that controls the parsing operation. This parameter is normally set to NULL.</param>
	''' <param name="ppidl">Address of a pointer to a variable of type ITEMIDLIST that receives the item identifier list for the object.</param>
	''' <param name="AttrToQuery">ULONG value that specifies the attributes to query.</param>
	''' <param name="ResultAttr">Pointer to a ULONG. On return, those attributes that are true for the object and were requested in AttrToQuery will be set. </param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHParseDisplayName(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszName As String, ByVal pBndContext As IntPtr, <System.Runtime.InteropServices.Out()> ByRef ppidl As IntPtr, ByVal AttrToQuery As UInt32, <System.Runtime.InteropServices.Out()> ByRef ResultAttr As UInt32) As Int32
	End Function

	''' <summary>
	''' Retrieves the IShellFolder interface for the desktop folder,
	''' which is the root of the Shell's namespace. 
	''' </summary>
	''' <param name="ppshf">Address that receives an IShellFolder interface pointer for the desktop folder.</param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHGetDesktopFolder(<System.Runtime.InteropServices.Out()> ByRef ppshf As IntPtr) As Int32
	End Function

	''' <summary>
	''' This function takes the fully-qualified pointer to an item
	''' identifier list (PIDL) of a namespace object, and returns a specified
	''' interface pointer on the parent object.
	''' </summary>
	''' <param name="pidl">The item's PIDL. </param>
	''' <param name="riid">The REFIID of one of the interfaces exposed by the item's parent object.</param>
	''' <param name="ppv">A pointer to the interface specified by riid. You must release the object when you are finished.</param>
	''' <param name="ppidlLast">// The item's PIDL relative to the parent folder. This PIDL can be used with many of the methods supported by the parent folder's interfaces. If you set ppidlLast to NULL, the PIDL will not be returned. </param>
	''' <returns></returns>
	<DllImport("shell32.dll")> _
	Public Shared Function SHBindToParent(ByVal pidl As IntPtr, <MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <System.Runtime.InteropServices.Out()> ByRef ppv As IntPtr, ByRef ppidlLast As IntPtr) As Int32
	End Function

	''' <summary>
	''' Accepts a STRRET structure returned by
	''' ShellFolder::GetDisplayNameOf that contains or points to a string, and then
	''' returns that string as a BSTR.
	''' </summary>
	''' <param name="pstr">Pointer to a STRRET structure.</param>
	''' <param name="pidl">Pointer to an ITEMIDLIST uniquely identifying a file object or subfolder relative to the parent folder.</param>
	''' <param name="pbstr">Pointer to a variable of type BSTR that contains the converted string.</param>
	''' <returns></returns>
        <DllImport("shlwapi.dll")> _
        Public Shared Function StrRetToBSTR(ByRef pstr As STRRET, ByVal pidl As IntPtr, <System.Runtime.InteropServices.Out(), MarshalAs(UnmanagedType.BStr)> ByRef pbstr As String) As Int32
        End Function

        ''' <summary>
        ''' Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf,
        ''' converts it to a string, and places the result in a buffer. 
        ''' </summary>
        ''' <param name="pstr">Pointer to the STRRET structure. When the function returns, this pointer will no longer be valid.</param>
        ''' <param name="pidl">Pointer to the item's ITEMIDLIST structure.</param>
        ''' <param name="pszBuf">Buffer to hold the display name. It will be returned as a null-terminated string. If cchBuf is too small, the name will be truncated to fit.</param>
        ''' <param name="cchBuf">Size of pszBuf, in characters. If cchBuf is too small, the string will be truncated to fit. </param>
        ''' <returns></returns>
        <DllImport("shlwapi.dll")> _
        Public Shared Function StrRetToBuf(ByRef pstr As STRRET, ByVal pidl As IntPtr, ByVal pszBuf As StringBuilder, ByVal cchBuf As UInt32) As Int32
        End Function

        ''' <summary>
        ''' Displays a dialog box that enables the user to select a Shell folder. 
        ''' </summary>
        ''' <param name="lbpi">// Pointer to a BROWSEINFO structure that contains information used to display the dialog box.</param>
        ''' <returns></returns>
        <DllImport("shell32.dll")> _
        Public Shared Function SHBrowseForFolder(ByRef lbpi As BROWSEINFO) As IntPtr
        End Function

        Public Delegate Function BrowseCallbackProc(ByVal hwnd As IntPtr, ByVal uMsg As Integer, ByVal lParam As IntPtr, ByVal lpData As IntPtr) As IntPtr
#End Region
  End Class
End Namespace
